/**
 * 
 */
package org.project.product.android.pfe.fanta.view;

import org.project.product.android.pfe.fanta.R;
import org.project.product.android.pfe.fanta.domain.Product;

import android.content.Context;
import android.view.LayoutInflater;
import android.widget.LinearLayout;
import android.widget.TextView;

/**
 * @author JBromo
 * 
 */
public class ProductItemView extends LinearLayout {

	private TextView texte;
	private TextView description;
	private TextView poids;
	private TextView codeBarre;

	public ProductItemView(Context context, Product item) {
		super(context);
		LayoutInflater.from(context).inflate(R.layout.product_item, this, true);
		initView();
		reuse(item);
	}

	private void initView() {
		texte = (TextView) findViewById(R.id.product_name);
		description = (TextView) findViewById(R.id.product_description);
		poids = (TextView) findViewById(R.id.product_poids);
		codeBarre = (TextView) findViewById(R.id.product_codebarre);

	}

	public void reuse(final Product item) {
		texte.setText(item.getNom());
		description.setText("Description " + item.getDescription());
		codeBarre.setText("Code Barre " + item.getCodBarre());
		poids.setText("Poids: " + String.valueOf(item.getPoids()) + "   Prix :"
		        + item.getPrix());

	}
}
